---
title: 'getAllSessionStorage | Cypress Documentation'
description: Get sessionStorage data for all origins with which the test has interacted in Cypress.
sidebar_label: getAllSessionStorage
---

<ProductHeading product="app" />

# getAllSessionStorage

Get
[`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage)
data for all origins with which the test has interacted.

## Syntax

```javascript
cy.getAllSessionStorage()
cy.getAllSessionStorage(options)
```

### Usage

<Icon name="check-circle" color="green" /> **Correct Usage**

```javascript
cy.getAllSessionStorage()
```

### Arguments

<Icon name="angle-right" /> **options _(Object)_**

Pass in an options object to change the default behavior of
`cy.getAllSessionStorage()`.

| Option | Default | Description                                                                         |
| ------ | ------- | ----------------------------------------------------------------------------------- |
| `log`  | `true`  | Displays the command in the [Command log](/app/core-concepts/open-mode#Command-Log) |

<HeaderYields />

`cy.getAllSessionStorage()` yields an object where the keys are origins and the
values are key-value pairs of `sessionStorage` data.

For example, if `key1` is set to `value1` on `https://example.cypress.io` and
`key2` is set to `value2` on `https://www.cypress-dx.com`,
`cy.getAllSessionStorage()` will yield:

```js
{
  'https://example.cypress.io': {
    key1: 'value1',
  },
  'https://www.cypress-dx.com': {
    key2: 'value2',
  },
}
```

## Examples

### Get all sessionStorage

```javascript
cy.visit('/users', {
  onBeforeLoad(win) {
    win.sessionStorage.setItem('key', 'value')
  },
})

cy.getAllSessionStorage().then((result) => {
  expect(result).to.deep.equal({
    'http://localhost:8080': {
      key: 'value',
    },
  })
})
```

## Rules

<HeaderRequirements />

- `cy.getAllSessionStorage()` requires being chained off of `cy`.

<HeaderAssertions />

- `cy.getAllSessionStorage()` will only run assertions you have chained once,
  and will not [retry](/app/core-concepts/retry-ability).

<HeaderTimeouts />

- `cy.getAllSessionStorage()` cannot time out.

## See also

- [`cy.clearAllLocalStorage()`](/api/commands/clearalllocalstorage)
- [`cy.clearAllSessionStorage()`](/api/commands/clearallsessionstorage)
- [`cy.clearCookies()`](/api/commands/clearcookies)
- [`cy.clearLocalStorage()`](/api/commands/clearlocalstorage)
- [`cy.getAllLocalStorage()`](/api/commands/getalllocalstorage)
